import wmi
import base64
import datetime
#解密顺序:
#先把数据前缀去除再将等号重置
#对加密数据进行5次解密
#对主板序列进行base64加密后去加密数据的3-12位并转换大写
nowday,nowtime = str(datetime.datetime.now()).split(".")[0].split(" ")
s = wmi.WMI()
jh1=input("请输入需要解密的内容:")
mainboard=[]
jh2=str(jh1.lstrip("key{").replace("}","="))
for i in range(5):
    try:
        jh2=base64.b64decode(jh2.encode("UTF-8")).decode("UTF-8")
    except:
        print("验证失败，请检查校验码是否正确！")
        input("点击换行继续...")
        quit()
for board_id in s.Win32_BaseBoard():
    mainboard.append(board_id.SerialNumber.strip('.').replace("/",""))
zcm=base64.b64encode(mainboard[0].encode("utf-8")).decode("utf-8")[3:12].upper()
for r in range(len(zcm)):
    if(jh2[r]!=zcm[r]):
        print("验证失败，请检查校验码是否正确！")
        quit()
print("解密成功")
